// Bootstrap
function bootstrap() {
wp_enqueue_style( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', null, null );
wp_enqueue_style( 'font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', null, null );
wp_enqueue_script( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', array(), null, true );
}
add_action( 'wp_enqueue_scripts', 'bootstrap' );
// masonry
function masonry() {
wp_enqueue_script( 'masonry', 'https://npmcdn.com/masonry-layout@4.0/dist/masonry.pkgd.min.js', array(), null, false );
}
add_action( 'wp_enqueue_scripts', 'masonry' );
// flickity
function flickity() {
wp_enqueue_style( 'flickity', 'https://npmcdn.com/flickity@1.2/dist/flickity.min.css', null, null );
wp_enqueue_script( 'flickity', 'https://npmcdn.com/flickity@1.2/dist/flickity.pkgd.min.js', array(), null, true );
}
add_action( 'wp_enqueue_scripts', 'flickity' );
// fancybox
function touchTouch() {
wp_enqueue_script( 'fancybox', 'https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', array(), null, true );
wp_enqueue_style( 'fancybox', 'https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css', null, true );
}
add_action( 'wp_enqueue_scripts', 'touchTouch' );
// Theme CSS
function theme_style() {
wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'theme_style' );
// jquery latest
function jquery() {
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://code.jquery.com/jquery-latest.js"), false);
wp_enqueue_script('jquery');
}
add_action( 'wp_enqueue_scripts', 'jquery' );
// Add ie conditional html5 shim to header
function add_ie_html5_shim () {
echo '';
}
add_action('wp_head', 'add_ie_html5_shim');
// Add Feature Images
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
// Theme Menu Setup
add_action( 'after_setup_theme', 'wpt_setup' );
if ( ! function_exists( 'wpt_setup' ) ):
function wpt_setup() {
register_nav_menu( 'primary', __( 'Primary navigation', 'wptuts' ) );
register_nav_menu( 'footer', __( 'Footer navigation', 'wptuts' ) );
}
endif;
require_once('assets/inc/wp_bootstrap_navwalker.php');
// SEO Yeost Low
add_filter( 'wpseo_metabox_prio', function() { return 'low';});
// Paginacion
function wp_bs_pagination($pages = '', $range = 4){
$showitems = ($range * 2) + 1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == ''){
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages){
$pages = 1;
}
}
if(1 != $pages){
echo '
';
echo '";
echo "
";
}
}
// Limit exceprt
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
return $excerpt;
}
// CMB2
add_action( 'cmb2_admin_init', 'cmb2_articulo_metaboxes' );
function cmb2_articulo_metaboxes() {
$prefix = '_opciones_';
$cmb = new_cmb2_box( array(
'id' => 'opciones_metabox',
'title' => __( 'Opciones', 'cmb2' ),
'object_types' => array( 'post', ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
) );
$cmb->add_field( array(
'name' => 'Destacado',
'desc' => 'Destacar el articulo en el inicio',
'id' => $prefix . 'radio_inline',
'type' => 'radio_inline',
'show_option_none' => 'No',
'options' => array(
'si' => __( 'Si', 'cmb2' )
),
) );
$cmb->add_field( array(
'name' => 'Galeria',
'desc' => '',
'id' => $prefix . 'file_list',
'type' => 'file_list',
'preview_size' => array( 100, 100 ),
) );
$cmb->add_field( array(
'name' => 'Ubicación',
'desc' => 'Drag the marker to set the exact location',
'id' => $prefix . 'location',
'type' => 'pw_map'
) );
}
// CMB2 Gallery
function cmb2_output_file_list( $file_list_meta_key, $img_size = 'medium' ) {
$files = get_post_meta( get_the_ID(), $file_list_meta_key, 1 );
if (!empty($files)) { ?>
foreach ( (array) $files as $attachment_id => $attachment_url ) { ?>
$image_src = wp_get_attachment_image_src( $attachment_id, $img_size ); ?>
$attachment_title = get_the_title($attachment_id); ?>
} ?>
}
}
// CMB2 REVISTA
add_action( 'cmb2_admin_init', 'cmb2_revista_metaboxes' );
function cmb2_revista_metaboxes() {
$prefix = '_revista_';
$cmb = new_cmb2_box( array(
'id' => 'revista_metabox',
'title' => __( 'Opciones', 'cmb2' ),
'object_types' => array( 'revista', ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
) );
$cmb->add_field( array(
'name' => 'Link',
'desc' => 'Ejemplo: https://issuu.com/tourmagazinemx/docs/tm21',
'default' => 'https://issuu.com/tourmagazinemx/docs/',
'id' => $prefix . 'radio_inline',
'type' => 'text',
) );
}
// CMB2 > sitio web
add_action( 'cmb2_admin_init', 'cmb2_ajustes_info_metaboxes' );
function cmb2_ajustes_info_metaboxes() {
$prefix = '_ajustes_info_';
$cmb = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => esc_html__( 'Información', 'cmb2' ),
'object_types' => array( 'ajuste' ), // Post type
'show_on' => array( 'key' => 'id', 'value' => array( 1555 ) ),
) );
$cmb->add_field( array(
'name' => esc_html__( 'Teléfono 1', 'cmb2' ),
'id' => $prefix . 'tel01',
'type' => 'text',
'show_on_cb' => 'yourprefix_hide_if_no_cats',
) );
$cmb->add_field( array(
'name' => esc_html__( 'Teléfono 2', 'cmb2' ),
'id' => $prefix . 'tel02',
'type' => 'text',
'show_on_cb' => 'yourprefix_hide_if_no_cats',
) );
$cmb->add_field( array(
'name' => esc_html__( 'Domicilio', 'cmb2' ),
'id' => $prefix . 'domicilio',
'type' => 'wysiwyg',
'options' => array(
'textarea_rows' => 5,
),
) );
}
add_action( 'cmb2_admin_init', 'cmb2_ajustes_adsuperior_metaboxes' );
function cmb2_ajustes_adsuperior_metaboxes() {
$prefix = '_ajustes_adsuperior_';
$cmb = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => esc_html__( 'Información', 'cmb2' ),
'object_types' => array( 'ajuste' ),
'show_on' => array( 'key' => 'id', 'value' => array( 1556 ) ),
) );
$group_field_id = $cmb->add_field( array(
'id' => 'wiki_test_repeat_group',
'type' => 'group',
'options' => array(
'group_title' => __( 'Anuncio {#}', 'cmb2' ),
'add_button' => __( 'Agregar', 'cmb2' ),
'remove_button' => __( 'Eliminar', 'cmb2' ),
'sortable' => true,
),
) );
$cmb->add_group_field( $group_field_id, array(
'name' => __( 'Link', 'cmb2' ),
'id' => $prefix . 'url',
'type' => 'text_url',
) );
$cmb->add_group_field( $group_field_id, array(
'name' => 'Imagen Desktop',
'desc' => '720x90 px',
'id' => $prefix . 'img-dsk',
'type' => 'file',
'options' => array(
'url' => false,
),
'text' => array(
'add_upload_file_text' => 'Agregar Imagen'
),
'query_args' => array(
'type' => array(
'image/gif',
'image/jpeg',
'image/png',
),
),
'preview_size' => 'large',
) );
$cmb->add_group_field( $group_field_id, array(
'name' => 'Imagen Movil',
'desc' => '320x100 px',
'id' => $prefix . 'img-mvl',
'type' => 'file',
'options' => array(
'url' => false,
),
'text' => array(
'add_upload_file_text' => 'Agregar Imagen'
),
'query_args' => array(
'type' => array(
'image/gif',
'image/jpeg',
'image/png',
),
),
'preview_size' => 'large',
) );
}
add_action( 'cmb2_admin_init', 'cmb2_ajustes_adarticulo_metaboxes' );
function cmb2_ajustes_adarticulo_metaboxes() {
$prefix = '_ajustes_adarticulo_';
$cmb = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => esc_html__( 'Información', 'cmb2' ),
'object_types' => array( 'ajuste' ), // Post type
'show_on' => array( 'key' => 'id', 'value' => array( 1557 ) ),
) );
$group_field_id = $cmb->add_field( array(
'id' => 'wiki_test_repeat_group',
'type' => 'group',
'options' => array(
'group_title' => __( 'Anuncio {#}', 'cmb2' ),
'add_button' => __( 'Agregar', 'cmb2' ),
'remove_button' => __( 'Eliminar', 'cmb2' ),
'sortable' => true,
),
) );
$cmb->add_group_field( $group_field_id, array(
'name' => __( 'Link', 'cmb2' ),
'id' => $prefix . 'url',
'type' => 'text_url',
) );
$cmb->add_group_field( $group_field_id, array(
'name' => 'Imagen Desktop',
'desc' => '580x400 px',
'id' => $prefix . 'img-dsk',
'type' => 'file',
'options' => array(
'url' => false,
),
'text' => array(
'add_upload_file_text' => 'Agregar Imagen'
),
'query_args' => array(
'type' => array(
'image/gif',
'image/jpeg',
'image/png',
),
),
'preview_size' => 'large',
) );
$cmb->add_group_field( $group_field_id, array(
'name' => 'Imagen Movil',
'desc' => '300x250 px',
'id' => $prefix . 'img-mvl',
'type' => 'file',
'options' => array(
'url' => false,
),
'text' => array(
'add_upload_file_text' => 'Agregar Imagen'
),
'query_args' => array(
'type' => array(
'image/gif',
'image/jpeg',
'image/png',
),
),
'preview_size' => 'large',
) );
}
// Move the Sharing and Like buttons
function jptweak_remove_share() {
remove_filter( 'the_content', 'sharing_display',19 );
remove_filter( 'the_excerpt', 'sharing_display',19 );
if ( class_exists( 'Jetpack_Likes' ) ) {
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
}
}
add_action( 'loop_start', 'jptweak_remove_share' );
?>